package com.parktech.sun.domain.model.aboutus;

import com.parktech.sun.domain.model.BaseEntity;
import com.parktech.sun.domain.model.ContentEntity;
import com.parktech.sun.utils.HTMLHelper;
import org.xml.sax.SAXException;

import javax.persistence.*;
import java.io.IOException;

/**
 * User: Think
 * Date: 2010-12-20
 * Time: 1:59:29
 */
@Entity
public class AboutUs extends BaseEntity {

    private String category;

    private String title;

    private String content;

    public AboutUs() {
    }

    public AboutUs(String category) {
        this.category = category;
    }

    @Id
    @GeneratedValue(strategy = GenerationType.AUTO)
    public Long getId() {
        return id;
    }

    public String getTitle() {
        return title;
    }

    public void setTitle(String title) {
        this.title = title;
    }

    public String getCategory() {
        return category;
    }

    public void setCategory(String category) {
        this.category = category;
    }

    @Lob
    @Basic(fetch = FetchType.LAZY)
    @Column(length = 2147483647)
    public String getContent() {
        return content;
    }

    public void setContent(String content) {
        this.content = content;
    }
    @Transient
    public String getContentText() {
        try {
            return HTMLHelper.getContentText(content);
        } catch (IOException e) {
            e.printStackTrace();
            return content;
        } catch (SAXException e) {
            e.printStackTrace();
            return content;
        }
    }
}
